﻿<Window x:Class="SEToolbox.Views.WindowExplorer"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:commands="clr-namespace:SEToolbox.Services"
        xmlns:controls="clr-namespace:SEToolbox.Controls"
        xmlns:views="clr-namespace:SEToolbox.Views"
        xmlns:vm="clr-namespace:SEToolbox.ViewModels"
        xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
        xmlns:converters="clr-namespace:SEToolbox.Converters"
        xmlns:interfaces="clr-namespace:SEToolbox.Interfaces"
        xmlns:lex="http://wpflocalizeextension.codeplex.com"
        lex:LocalizeDictionary.DesignCulture="en"
        lex:ResxLocalizationProvider.DefaultAssembly="SEToolbox"
        lex:ResxLocalizationProvider.DefaultDictionary="Resources"
        Height="600" Width="800" MinHeight="320" MinWidth="480" ResizeMode="CanResizeWithGrip" 
        WindowStartupLocation="CenterScreen" Icon="/SEToolbox;component/app.ico"
        commands:DialogCloser.DialogResult="{Binding CloseResult}"
        commands:DialogService.IsRegisteredView="True">
    <i:Interaction.Triggers>
        <i:EventTrigger EventName="Closing">
            <commands:CommandAction Command="{Binding ClosingCommand}" EventArgs="True" />
        </i:EventTrigger>
    </i:Interaction.Triggers>
    <Window.Resources>
        <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
        <converters:EnumToResouceConverter x:Key="EnumToResouceConverter"/>
        <converters:BusyMouseConverter x:Key="BusyMouseConverter" />
        <converters:ResouceToImageConverter x:Key="ResouceToImageConverter"/>
        <converters:DistanceConverter x:Key="DistanceConverter"/>
        <converters:I18NFormatterConverter x:Key="I18NFormatter"  />
    </Window.Resources>
    <Window.Cursor>
        <Binding Path="IsBusy" Converter="{StaticResource BusyMouseConverter}"/>
    </Window.Cursor>
    <Window.Title>
        <MultiBinding Converter="{StaticResource I18NFormatter}" ConverterParameter="WindowMainTitle">
            <Binding Path="ActiveWorld.SessionName"/>
            <Binding Path="ActiveWorld.SaveType" Converter="{StaticResource EnumToResouceConverter}"/>
        </MultiBinding>
    </Window.Title>
    <Window.TaskbarItemInfo>
        <TaskbarItemInfo ProgressState="{Binding ProgressState}" ProgressValue="{Binding ProgressValue}" />
    </Window.TaskbarItemInfo>
    <Window.InputBindings>
        <KeyBinding Key="O" Modifiers="Control" Command="{Binding OpenCommand}" />
        <KeyBinding Key="S" Modifiers="Control" Command="{Binding SaveCommand}" />
        <KeyBinding Key="R" Modifiers="Control" Command="{Binding ReloadCommand}" />
    </Window.InputBindings>
    <Grid IsEnabled="{Binding IsActive}">
        <DockPanel>
            <Menu DockPanel.Dock="Top">
                <Menu.ItemsPanel>
                    <ItemsPanelTemplate>
                        <DockPanel HorizontalAlignment="Stretch" Height="22"/>
                    </ItemsPanelTemplate>
                </Menu.ItemsPanel>
                <MenuItem  Header="_File" Style="{StaticResource ToolBarTopMenuitem}">
                    <MenuItem.Icon>
                        <Image Width="16" Height="16" Source="{Binding Converter={StaticResource ResouceToImageConverter}, ConverterParameter=document}"/>
                    </MenuItem.Icon>
                    <MenuItem Command="{Binding OpenCommand}" Header="_Open (Ctrl+O)">
                        <MenuItem.Icon>
                            <Image Width="16" Height="16" Source="{Binding Converter={StaticResource ResouceToImageConverter}, ConverterParameter=folder}"/>
                        </MenuItem.Icon>
                    </MenuItem>
                    <MenuItem Command="{Binding SaveCommand}" Header="_Save (Ctrl+S)">
                        <MenuItem.Icon>
                            <Image Width="16" Height="16" Source="{Binding Converter={StaticResource ResouceToImageConverter}, ConverterParameter=disk_blue}"/>
                        </MenuItem.Icon>
                    </MenuItem>
                    <!--<MenuItem Command="{Binding SaveAsCommand}" Header="Save _As (Ctrl+A)">
                        <MenuItem.Icon>
                            <Image Width="16" Height="16" Source="{Binding Converter={StaticResource ResouceToImageConverter}, ConverterParameter=disk_blue}"/>
                        </MenuItem.Icon>
                    </MenuItem>-->
                    <Separator />
                    <MenuItem Command="{Binding ReloadCommand}" Header="_Reload (Ctrl+R)" ToolTip="Undo any changes, and reload world again.">
                        <MenuItem.Icon>
                            <Image Width="16" Height="16" Source="{Binding Converter={StaticResource ResouceToImageConverter}, ConverterParameter=refresh}"/>
                        </MenuItem.Icon>
                    </MenuItem>
                </MenuItem>
                <Separator Style="{StaticResource DockPanelSeparator}" />
                <MenuItem Header="_Import" Command="{Binding IsActiveCommand}" Style="{StaticResource ToolBarTopMenuitem}">
                    <MenuItem.Icon>
                        <Image Width="16" Height="16" Source="{Binding Converter={StaticResource ResouceToImageConverter}, ConverterParameter=import1}" />
                    </MenuItem.Icon>
                    <MenuItem Header="Asteroid" Command="{Binding ImportVoxelCommand}">
                        <MenuItem.Icon>
                            <Image Width="16" Height="16" Source="{Binding Converter={StaticResource ResouceToImageConverter}, ConverterParameter=asteroid}" />
                        </MenuItem.Icon>
                    </MenuItem>
                    <MenuItem Header="3D Model for Asteroid" Command="{Binding ImportAsteroidModelCommand}">
                        <MenuItem.Icon>
                            <Image Width="16" Height="16" Source="{Binding Converter={StaticResource ResouceToImageConverter}, ConverterParameter=Asteroid_model}" />
                        </MenuItem.Icon>
                    </MenuItem>
                    <Separator/>
                    <MenuItem Header="Image" Command="{Binding ImportImageCommand}" ToolTip="Import a image into a flat array of armor, with color matched to each pixel in the image.">
                        <MenuItem.Icon>
                            <Image Width="16" Height="16" Source="{Binding Converter={StaticResource ResouceToImageConverter}, ConverterParameter=photo_scenery}" />
                        </MenuItem.Icon>
                    </MenuItem>
                    <Separator/>
                    <MenuItem Header="3D Model" Command="{Binding ImportModelCommand}">
                        <MenuItem.Icon>
                            <Image Width="16" Height="16" Source="{Binding Converter={StaticResource ResouceToImageConverter}, ConverterParameter=icecube}" />
                        </MenuItem.Icon>
                    </MenuItem>
                    <Separator/>
                    <MenuItem Header="Sandbox Content files" Command="{Binding ImportSandboxObjectCommand}" ToolTip="Import previously exported ships and station .sbc files.">
                        <MenuItem.Icon>
                            <Image Width="16" Height="16" Source="{Binding Converter={StaticResource ResouceToImageConverter}, ConverterParameter=SECubes16}" />
                        </MenuItem.Icon>
                    </MenuItem>
                </MenuItem>
                <MenuItem Header="Export" Command="{Binding IsActiveCommand}" Style="{StaticResource ToolBarTopMenuitem}">
                    <MenuItem.Icon>
                        <Image Width="16" Height="16" Source="{Binding Converter={StaticResource ResouceToImageConverter}, ConverterParameter=export}" />
                    </MenuItem.Icon>
                    <MenuItem Header="Export with owner and MedBay" Command="{Binding ExportSandboxObjectCommand}" ToolTip="Export ships and stations to an .xml file, to store, allowing import into other worlds.">
                        <MenuItem.Icon>
                            <Image Width="16" Height="16" Source="{Binding Converter={StaticResource ResouceToImageConverter}, ConverterParameter=export}" />
                        </MenuItem.Icon>
                    </MenuItem>
                    <MenuItem Header="Export without owner and MedBay" Command="{Binding ExportBasicSandboxObjectCommand}" ToolTip="Export ships and stations to an .sbc file, to store, allowing import into other worlds.">
                        <MenuItem.Icon>
                            <Image Width="16" Height="16" Source="{Binding Converter={StaticResource ResouceToImageConverter}, ConverterParameter=export}" />
                        </MenuItem.Icon>
                    </MenuItem>
                    <MenuItem Header="Export as prefab" Command="{Binding ExportPrefabObjectCommand}" ToolTip="Export all ships and stations to a single an prefab .sbc file.">
                        <MenuItem.Icon>
                            <Image Width="16" Height="16" Source="{Binding Converter={StaticResource ResouceToImageConverter}, ConverterParameter=export}" />
                        </MenuItem.Icon>
                    </MenuItem>
                </MenuItem>
                <MenuItem Header="_Create" Command="{Binding IsActiveCommand}" Style="{StaticResource ToolBarTopMenuitem}">
                    <MenuItem.Icon>
                        <Image Width="16" Height="16" Source="{Binding Converter={StaticResource ResouceToImageConverter}, ConverterParameter=package_add}" />
                    </MenuItem.Icon>
                    <MenuItem Header="Create Component/Item" Command="{Binding CreateFloatingItemCommand}">
                        <MenuItem.Icon>
                            <Image Width="16" Height="16" Source="{Binding Converter={StaticResource ResouceToImageConverter}, ConverterParameter=screwdriver}" />
                        </MenuItem.Icon>
                    </MenuItem>
                    <MenuItem Header="Generate Asteroid Field" Command="{Binding GenerateVoxelFieldCommand}">
                        <MenuItem.Icon>
                            <Image Width="16" Height="16" Source="{Binding Converter={StaticResource ResouceToImageConverter}, ConverterParameter=asteroid}" />
                        </MenuItem.Icon>
                    </MenuItem>
                </MenuItem>
                <MenuItem Header="_Selection" Command="{Binding IsActiveCommand}" Style="{StaticResource ToolBarTopMenuitem}">
                    <MenuItem.Icon>
                        <Image Width="16" Height="16" Source="{Binding Converter={StaticResource ResouceToImageConverter}, ConverterParameter=selection}" />
                    </MenuItem.Icon>
                    <MenuItem Command="{Binding DeleteObjectCommand}" Header="Delete">
                        <MenuItem.Icon>
                            <Image Width="16" Height="16" Source="{Binding Converter={StaticResource ResouceToImageConverter}, ConverterParameter=delete2}"/>
                        </MenuItem.Icon>
                    </MenuItem>
                    <Separator/>
                    <MenuItem Command="{Binding GroupMoveCommand}" Header="Group Move">
                        <MenuItem.Icon>
                            <Image Width="16" Height="16" Source="{Binding Converter={StaticResource ResouceToImageConverter}, ConverterParameter=fit_to_size}"/>
                        </MenuItem.Icon>
                    </MenuItem>
                    <Separator/>
                    <MenuItem Command="{Binding RepairShipsCommand}" Header="Repair">
                        <MenuItem.Icon>
                            <Image Width="16" Height="16" Source="{Binding Converter={StaticResource ResouceToImageConverter}, ConverterParameter=wrench}"/>
                        </MenuItem.Icon>
                    </MenuItem>
                    <MenuItem Header="Reset all Speed" Command="{Binding ResetVelocityCommand}" ToolTip="Set Linear and Rotation Velocity to zero (0).">
                        <MenuItem.Icon>
                            <Image Width="16" Height="16" Source="{Binding Converter={StaticResource ResouceToImageConverter}, ConverterParameter=media_stop}" />
                        </MenuItem.Icon>
                    </MenuItem>
                    <MenuItem Command="{Binding RejoinShipCommand}" Header="Rejoin Ship" ToolTip="Rejoins 2 parts from a broken ship back togeather">
                        <MenuItem.Icon>
                            <Image Width="16" Height="16" Source="{Binding Converter={StaticResource ResouceToImageConverter}, ConverterParameter=first_aid}"/>
                        </MenuItem.Icon>
                    </MenuItem>
                    <MenuItem Command="{Binding JoinShipPartsCommand}" Header="Merge 2 Ships into 1" ToolTip="Joins 2 foriegn parts to form a new ship">
                        <MenuItem.Icon>
                            <Image Width="16" Height="16" Source="{Binding Converter={StaticResource ResouceToImageConverter}, ConverterParameter=components}"/>
                        </MenuItem.Icon>
                    </MenuItem>
                    <Separator/>
                    <MenuItem Command="{Binding VoxelMergeCommand}" Header="Merge 2 Asteroids into 1" ToolTip="Merge 2 asteroids to create a new asteroid">
                        <MenuItem.Icon>
                            <Image Width="16" Height="16" Source="{Binding Converter={StaticResource ResouceToImageConverter}, ConverterParameter=asteroid}"/>
                        </MenuItem.Icon>
                    </MenuItem>
                </MenuItem>
                <Separator Style="{StaticResource DockPanelSeparator}" />
                <MenuItem Header="_World" Style="{StaticResource ToolBarTopMenuitem}">
                    <MenuItem.Icon>
                        <Image Width="16" Height="16" Source="{Binding Converter={StaticResource ResouceToImageConverter}, ConverterParameter=SpaceEngineers16}" />
                    </MenuItem.Icon>
                    <MenuItem Header="_Report all resources" Command="{Binding WorldReportCommand}">
                        <MenuItem.Icon>
                            <Image Width="16" Height="16" Source="{Binding Converter={StaticResource ResouceToImageConverter}, ConverterParameter=document_pulse}" />
                        </MenuItem.Icon>
                    </MenuItem>
                    <MenuItem Header="Open _Folder" Command="{Binding OpenFolderCommand}">
                        <MenuItem.Icon>
                            <Image Width="16" Height="16" Source="{Binding Converter={StaticResource ResouceToImageConverter}, ConverterParameter=folder}" />
                        </MenuItem.Icon>
                    </MenuItem>
                    <MenuItem Header="_View current Sandbox raw" Command="{Binding ViewSandboxCommand}">
                        <MenuItem.Icon>
                            <Image Width="16" Height="16" Source="{Binding Converter={StaticResource ResouceToImageConverter}, ConverterParameter=document_view}" />
                        </MenuItem.Icon>
                    </MenuItem>
                    <MenuItem Header="View _Steam Workshop" Command="{Binding OpenWorkshopCommand}">
                        <MenuItem.Icon>
                            <Image Width="16" Height="16" Source="{Binding Converter={StaticResource ResouceToImageConverter}, ConverterParameter=workshop16}" />
                        </MenuItem.Icon>
                    </MenuItem>
                    <Separator/>
                    <MenuItem Header="_Component List" Command="{Binding OpenComponentListCommand}">
                        <MenuItem.Icon>
                            <Image Width="16" Height="16" Source="{Binding Converter={StaticResource ResouceToImageConverter}, ConverterParameter=form_green_view}" />
                        </MenuItem.Icon>
                    </MenuItem>
                </MenuItem>
                <Separator Style="{StaticResource DockPanelSeparator}" />
                <MenuItem HorizontalAlignment="Right" Header="_Options" Style="{StaticResource ToolBarTopMenuitem}">
                    <MenuItem.Icon>
                        <Image Width="16" Height="16" Source="{Binding Converter={StaticResource ResouceToImageConverter}, ConverterParameter=help}"/>
                    </MenuItem.Icon>
                    <MenuItem Command="{Binding LanguageCommand}" Header="_Languages" ItemsSource="{Binding Languages}">
                        <MenuItem.Resources>
                            <Image x:Shared="False" x:Key="MenuIcon" Width="16" Height="16" Source="{Binding ImageName, Converter={StaticResource ResouceToImageConverter}}"/>
                        </MenuItem.Resources>
                        <MenuItem.ItemContainerStyle>
                            <Style TargetType="MenuItem">
                                <Setter Property="Header" Value="{Binding Path=Name}"/>
                                <Setter Property="Command" Value="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=MenuItem}, Path=DataContext.SetLanguageCommand}" />
                                <Setter Property="CommandParameter" Value="{Binding Path=IetfLanguageTag}" />
                                <Setter Property="Icon" Value="{StaticResource MenuIcon}"/>
                            </Style>
                        </MenuItem.ItemContainerStyle>
                    </MenuItem>
                    <MenuItem Command="{Binding OpenSettingsCommand}" Header="_Settings"/>
                    <Separator/>
                    <MenuItem Command="{Binding OpenDocumentationLinkCommand}" Header="_Documentation">
                        <MenuItem.Icon>
                            <Image Width="16" Height="16" Source="{Binding Converter={StaticResource ResouceToImageConverter}, ConverterParameter=book_open2}"/>
                        </MenuItem.Icon>
                    </MenuItem>
                    <MenuItem Command="{Binding OpenSupportLinkCommand}" Header="Su_pport">
                        <MenuItem.Icon>
                            <Image Width="16" Height="16" Source="{Binding Converter={StaticResource ResouceToImageConverter}, ConverterParameter=message_edit}"/>
                        </MenuItem.Icon>
                    </MenuItem>
                    <MenuItem Command="{Binding OpenUpdatesLinkCommand}" Header="Find _Updates">
                        <MenuItem.Icon>
                            <Image Width="16" Height="16" Source="{Binding Converter={StaticResource ResouceToImageConverter}, ConverterParameter=server_to_client}"/>
                        </MenuItem.Icon>
                    </MenuItem>
                    <Separator/>
                    <MenuItem Command="{Binding AboutCommand}" Header="_About">
                        <MenuItem.Icon>
                            <Image Width="16" Height="16" Source="{Binding Converter={StaticResource ResouceToImageConverter}, ConverterParameter=about}"/>
                        </MenuItem.Icon>
                    </MenuItem>
                </MenuItem>
            </Menu>
            <ToolBarPanel DockPanel.Dock="Top" >
                <ToolBar>
                    <Button Command="{Binding OpenCommand}" ToolTip="Open">
                        <Image Width="16" Height="16" Source="{Binding Converter={StaticResource ResouceToImageConverter}, ConverterParameter=folder}"/>
                    </Button>
                    <Button Command="{Binding SaveCommand}" ToolTip="Save">
                        <Image Width="16" Height="16" Source="{Binding Converter={StaticResource ResouceToImageConverter}, ConverterParameter=disk_blue}"/>
                    </Button>
                    <Separator />
                    <Button Command="{Binding RepairShipsCommand}" ToolTip="Repair">
                        <Image Width="16" Height="16" Source="{Binding Converter={StaticResource ResouceToImageConverter}, ConverterParameter=wrench}"/>
                    </Button>
                    <Button Command="{Binding GroupMoveCommand}" ToolTip="Group Move">
                        <Image Width="16" Height="16" Source="{Binding Converter={StaticResource ResouceToImageConverter}, ConverterParameter=fit_to_size}"/>
                    </Button>
                    <Separator />
                    <Button Command="{Binding CopyObjectGpsCommand}" ToolTip="Copy GPS">
                        <Image Width="16" Height="16" Source="{Binding Converter={StaticResource ResouceToImageConverter}, ConverterParameter=target}"/>
                    </Button>
                    <Separator />
                    <Button Command="{Binding DeleteObjectCommand}" ToolTip="Delete">
                        <Image Width="16" Height="16" Source="{Binding Converter={StaticResource ResouceToImageConverter}, ConverterParameter=delete2}"/>
                    </Button>
                </ToolBar>
            </ToolBarPanel>
            <ToolBarPanel DockPanel.Dock="Top" Visibility="{Binding IsDebugger, Converter={StaticResource BooleanToVisibilityConverter}}">
                <ToolBar>
                    <Button Content="Clear" Command="{Binding ClearCommand}"/>
                    <Button Content="Test1" ToolTip="Create test structure for smoothing." Command="{Binding Test1Command}"/>
                    <Button Content="Test2" ToolTip="Optimise structure" Command="{Binding Test2Command}"/>
                    <Button Content="Test3" ToolTip="Create 1/2 test model" Command="{Binding Test3Command}"/>
                    <Button Content="Test4" ToolTip="Mirror Structure" Command="{Binding Test4Command}"/>
                    <Button Content="Test5" ToolTip="Count orientations" Command="{Binding Test5Command}"/>
                    <Button Content="Test6" ToolTip="Test converter" Command="{Binding Test6Command}"/>
                </ToolBar>
            </ToolBarPanel>
            <StatusBar DockPanel.Dock="Bottom">
                <StatusBarItem>
                    <views:ControlSaveState />
                </StatusBarItem>
                <Separator/>
                <StatusBarItem>
                    <views:ControlBaseState/>
                </StatusBarItem>
                <Separator/>
                <StatusBarItem>
                    <!-- placeholder to maintain correct height for text -->
                    <TextBlock />
                </StatusBarItem>
                <!--<StatusBarItem HorizontalAlignment="Right" Margin="0,0,20,0">
                    <views:ControlBusyState />
                </StatusBarItem>-->
                <StatusBarItem HorizontalAlignment="Right" Margin="0,0,20,0">
                    <ProgressBar Value="{Binding Progress}" Maximum="{Binding MaximumProgress}" Width="100" Height="12" Visibility="{Binding ShowProgress, Converter={StaticResource BooleanToVisibilityConverter}}" />
                </StatusBarItem>
            </StatusBar>
            <Grid>
                <Grid.Style>
                    <Style TargetType="Grid">
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding DataContext.ActiveWorld, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}" Value="{x:Null}">
                                <Setter Property="IsEnabled" Value="False"/>
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </Grid.Style>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*" MinWidth="40"/>
                    <ColumnDefinition Width="4"/>
                    <ColumnDefinition Width="*" MinWidth="40"/>
                </Grid.ColumnDefinitions>
                <Grid Grid.Column="0">
                    <TabControl>
                        <TabItem Header="Craft/Objects">
                            <controls:SortableListView DisplayMemberPath="ClassType" SelectionMode="Extended" ItemsSource="{Binding Structures}" SelectedValue="{Binding SelectedStructure, Mode=TwoWay}"
                            ColumnHeaderArrowUpTemplate="{StaticResource HeaderTemplateArrowUp}" ColumnHeaderArrowDownTemplate="{StaticResource HeaderTemplateArrowDown}">
                                <ListView.Resources>
                                    <commands:Behaviors x:Key="dragBehavior" x:Shared="False">
                                        <commands:ListBoxItemDragBehavior DragSourceBinding="{Binding DataModel}" />
                                    </commands:Behaviors>
                                </ListView.Resources>
                                <ListView.ItemContainerStyle>
                                    <Style TargetType="ListViewItem">
                                        <Setter Property="commands:SupplementaryInteraction.Behaviors" Value="{StaticResource dragBehavior}"/>
                                        <Setter Property="HorizontalContentAlignment" Value="Stretch" />
                                    </Style>
                                </ListView.ItemContainerStyle>
                                <ListView.View>
                                    <GridView>
                                        <controls:SortableGridViewColumn SortBinding="{Binding ClassType}" Header="Type" Width="70">
                                            <GridViewColumn.CellTemplate>
                                                <DataTemplate>
                                                    <TextBlock Text="{Binding ClassType, Converter={StaticResource EnumToResouceConverter}}" TextWrapping="NoWrap" TextTrimming="CharacterEllipsis"/>
                                                </DataTemplate>
                                            </GridViewColumn.CellTemplate>
                                        </controls:SortableGridViewColumn>
                                        <controls:SortableGridViewColumn SortBinding="{Binding DisplayName}" Header="Name" Width="100">
                                            <GridViewColumn.CellTemplate>
                                                <DataTemplate>
                                                    <TextBlock Text="{Binding DisplayName}" TextWrapping="NoWrap" TextTrimming="CharacterEllipsis"/>
                                                </DataTemplate>
                                            </GridViewColumn.CellTemplate>
                                        </controls:SortableGridViewColumn>
                                        <controls:SortableGridViewColumn SortBinding="{Binding Description}" Header="Description" Width="100">
                                            <GridViewColumn.CellTemplate>
                                                <DataTemplate>
                                                    <TextBlock Text="{Binding Description}" TextWrapping="NoWrap" TextTrimming="CharacterEllipsis"/>
                                                </DataTemplate>
                                            </GridViewColumn.CellTemplate>
                                        </controls:SortableGridViewColumn>
                                        <controls:SortableGridViewColumn Width="70" SortBinding="{Binding PlayerDistance}" Header="Distance">
                                            <GridViewColumn.CellTemplate>
                                                <DataTemplate>
                                                    <TextBlock Text="{Binding PlayerDistance, Converter={StaticResource DistanceConverter}}" TextAlignment="Right" ToolTip="Distance to Player"/>
                                                </DataTemplate>
                                            </GridViewColumn.CellTemplate>
                                        </controls:SortableGridViewColumn>
                                        <controls:SortableGridViewColumn Width="70" SortBinding="{Binding Mass}" Header="Mass">
                                            <GridViewColumn.CellTemplate>
                                                <DataTemplate>
                                                    <TextBlock Text="{Binding Path=Mass, StringFormat='{}{0:#,##0.00}'}" TextAlignment="Right" ToolTip="Mass (Kg)"/>
                                                </DataTemplate>
                                            </GridViewColumn.CellTemplate>
                                        </controls:SortableGridViewColumn>
                                        <controls:SortableGridViewColumn Width="70" SortBinding="{Binding BlockCount}" Header="Cubes">
                                            <GridViewColumn.CellTemplate>
                                                <DataTemplate>
                                                    <TextBlock Text="{Binding Path=BlockCount, StringFormat='{}{0:#,##0}'}" TextAlignment="Right" ToolTip="Number of cubes"/>
                                                </DataTemplate>
                                            </GridViewColumn.CellTemplate>
                                        </controls:SortableGridViewColumn>
                                        <controls:SortableGridViewColumn Width="70" SortBinding="{Binding LinearVelocity}" Header="Velocity">
                                            <GridViewColumn.CellTemplate>
                                                <DataTemplate>
                                                    <TextBlock Text="{Binding Path=LinearVelocity, StringFormat='{}{0:#,##0.000}'}" TextAlignment="Right" ToolTip="Speed of object m/s"/>
                                                </DataTemplate>
                                            </GridViewColumn.CellTemplate>
                                        </controls:SortableGridViewColumn>
                                    </GridView>
                                </ListView.View>
                                <ListView.InputBindings>
                                    <KeyBinding Key="Delete" Command="{Binding DeleteObjectCommand}" />
                                </ListView.InputBindings>
                                <i:Interaction.Behaviors>
                                    <!-- This custom behavior that synchronizes the selected items with the view models collection -->
                                    <commands:SynchronizeSelectedItems Selections="{Binding Selections}"/>
                                    <commands:ListBoxDropBehavior AllowDropToSource="False" ShowDropIndicator="False" DropType="{x:Type interfaces:IStructureBase}"/>
                                </i:Interaction.Behaviors>
                                <ListBox.ContextMenu>
                                    <ContextMenu>
                                        <MenuItem Header="Delete" Command="{Binding DeleteObjectCommand}">
                                            <MenuItem.Icon>
                                                <Image Width="16" Height="16" Source="{Binding Converter={StaticResource ResouceToImageConverter}, ConverterParameter=delete2}" />
                                            </MenuItem.Icon>
                                        </MenuItem>
                                        <MenuItem Header="Copy GPS" Command="{Binding CopyObjectGpsCommand}">
                                            <MenuItem.Icon>
                                                <Image Width="16" Height="16" Source="{Binding Converter={StaticResource ResouceToImageConverter}, ConverterParameter=target}" />
                                            </MenuItem.Icon>
                                        </MenuItem>
                                    </ContextMenu>
                                </ListBox.ContextMenu>
                            </controls:SortableListView>
                        </TabItem>
                        <!--<TabItem Header="Factions/Owners">
                            
                        </TabItem>-->
                        <!--<TabItem Header="Properties">
                            
                        </TabItem>-->
                    </TabControl>
                </Grid>
                <GridSplitter Grid.Column="1" VerticalAlignment="Stretch" HorizontalAlignment="Center" Width="4"/>
                <Grid Grid.Column="2">
                    <ContentControl Content="{Binding SelectedStructure}">
                        <ContentControl.Resources>
                            <DataTemplate DataType="{x:Type vm:StructureCharacterViewModel}">
                                <views:ControlCharacter />
                            </DataTemplate>
                            <DataTemplate DataType="{x:Type vm:StructureVoxelViewModel}">
                                <views:ControlVoxel />
                            </DataTemplate>
                            <DataTemplate DataType="{x:Type vm:StructureCubeGridViewModel}">
                                <views:ControlCubeGrid />
                            </DataTemplate>
                            <DataTemplate DataType="{x:Type vm:StructureFloatingObjectViewModel}">
                                <views:ControlFloatingObject />
                            </DataTemplate>
                            <DataTemplate DataType="{x:Type vm:StructureMeteorViewModel}">
                                <views:ControlMeteor />
                            </DataTemplate>
                            <DataTemplate DataType="{x:Type vm:StructureUnknownViewModel}">
                                <views:ControlUnknown />
                            </DataTemplate>
                        </ContentControl.Resources>
                        <ContentControl.Style>
                            <Style TargetType="ContentControl">
                                <Style.Triggers>
                                    <DataTrigger Binding="{Binding DataContext.IsMultipleSelections, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}" Value="True">
                                        <Setter Property="Visibility" Value="Collapsed"/>
                                    </DataTrigger>
                                </Style.Triggers>
                            </Style>
                        </ContentControl.Style>
                    </ContentControl>
                    <ContentControl>
                        <ContentControl.Style>
                            <Style TargetType="ContentControl">
                                <Style.Triggers>
                                    <DataTrigger Binding="{Binding DataContext.IsMultipleSelections, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}" Value="False">
                                        <Setter Property="Visibility" Value="Collapsed"/>
                                    </DataTrigger>
                                </Style.Triggers>
                            </Style>
                        </ContentControl.Style>
                        <views:ControlMultiple />
                    </ContentControl>
                </Grid>
            </Grid>
        </DockPanel>
        <controls:BusyIndicator Visibility="{Binding IsBusy, Converter={StaticResource BooleanToVisibilityConverter}}" />
    </Grid>
</Window>
